home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / checkbox / scripts / gst_pipeline_test next >
Encoding:
Text File  |  2009-04-27  |  761 b   |  39 lines

  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import time
  5.  
  6. import pygst
  7. pygst.require("0.10")
  8.  
  9. from optparse import OptionParser
  10.  
  11.  
  12. def main(args):
  13.     import gst
  14.  
  15.     usage = "Usage: %prog [OPTIONS] PIPELINE"
  16.     parser = OptionParser(usage=usage)
  17.     parser.add_option("-t", "--timeout",
  18.         type="int",
  19.         default=0,
  20.         help="Timeout for running the pipeline.")
  21.     (options, args) = parser.parse_args(args)
  22.  
  23.     if len(args) != 1:
  24.         parser.error("Must provide a PIPELINE")
  25.  
  26.     pipeline = args[0]
  27.     element = gst.parse_launch(pipeline)
  28.     element.set_state(gst.STATE_PLAYING)
  29.  
  30.     if options.timeout:
  31.         time.sleep(options.timeout)
  32.  
  33.     element.set_state(gst.STATE_NULL)
  34.     return 0
  35.  
  36.  
  37. if __name__ == "__main__":
  38.     sys.exit(main(sys.argv[1:]))
  39.